package com.umeox.moto.common.decoration;

import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

public class VerticalItemDecoration extends RecyclerView.ItemDecoration {

    private int mVerticalSpace;

    public VerticalItemDecoration(int verticalSpace) {
        mVerticalSpace = verticalSpace;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        outRect.left = mVerticalSpace;
        outRect.right = mVerticalSpace;
        outRect.bottom = mVerticalSpace;

        // Add top margin only for the first item to avoid double space between items
        if (parent.getChildAdapterPosition(view) == 0)
            outRect.top = mVerticalSpace;
    }
}
